(define (fast-expt a b)
  (fast-expt-iter a b 0))

(define (fast-expt-iter a b n)
  (cond ((= b 0) n)
        ((even? b) (fast-expt-iter (* a 2) (/ b 2) n))
        (else (fast-expt-iter a (- b 1) (+ a n)))))
